import { message } from 'antd';
import { fetchShopList,getGoodsStockReportList } from './service';

const Model = {
  namespace: 'cubeStockReport',
  state: {
    shopList:[],
    stockList:[]
  },
  effects: {
    *fetchShopList({ payload }, { call,put }) {
      let result=yield call(fetchShopList, payload);
      if(result.code===0){
        yield put({
          type: 'common',
          payload: {
            shopList:result.data          }
        });
        return result.data;
      }else{
        message.error(result.message);
      }
    },
    *getGoodsStockReportList({ payload }, { call,put }) {
      let result=yield call(getGoodsStockReportList, payload);
      if(result.code===0){
        if(result.data ){
          yield put({
            type: 'common',
            payload: {
              stockList:result.data.list
            }
          });
        }
      }else{
        message.error(result.message);
      }
    }
  },
  reducers: {
    common(state, action) {
      return {
        ...state,
        ...action.payload,
      };
    },
  },
};
export default Model;
